/**
 * Created by zheng on 2018/7/2.
 */
var deleteindex = null
//当前保单所分配的状态ID
var state = 1

$(function () {
    //var binbin = 0;
    $('#dg').datagrid({
        url: '/accident/queryCaseItem',
        fit: true,
        fitColumns: true,
        //分页条
        pagination: true,
        // fit:true,
        //工具栏
        toolbar: "#tb",
        //单选
        singleSelect: true,
        columns: [[
            {field: 'x', checkbox: 'true'},
            {field: 'c_name', title: '受益人', width: 100},
            {
                field: 'cr_receivable_account', title: '收款账户', width: 100,

            },
            {field: 'cr_money', title: '赔偿金额', width: 100},
            {field: 'insure_odd_number', title: '保险单据', width: 100},

        ]],
        //新增
        border: false,
        cls: "table table-very table-basic"
    })


    //准备输入的对话弹框
    $('#dd').dialog({
        width: 700,
        height: 700,
        closed: true,
        // cache: false,
        modal: true,
        buttons: "#bb"
    })
    //订单详细
    $('#billDetail').dialog({
        width: 700,
        height: 700,
        closed: true,
        modal: true
    })
    //<!-- 准备投保人详情-->
    $('#applicantItem').dialog({
        width: 400,
        height: 500,
        closed: true,
        // cache: false,
        modal: true
    })

    //将工具栏所有的函数集合在一个对象中
    var cmdObj;
    cmdObj = {
        //刷新emp页面
        reload: function () {
            $('#dg').datagrid("load")
        },
        queryCaseItem: function () {

            var row = $('#dg').datagrid("getSelected");
            if (row == null) {
                $.messager.alert("温馨提示", "请选择一行");
                return;
            }
            console.log("row")
            console.log(row)
            $('#applicantItemForm').form("clear");
            $('#applicantItem').dialog("open")
            $('#applicantItem').dialog("setTitle", "查看案件详情明细")


            //回显
            $('#applicantItemForm').form('load', row);
            console.log(row);

        },
        //高级查询
        query: function () {
            var keyword = $("#keyword").textbox("getValue");
            var beginDate = $("#beginDate").textbox("getValue")
            var endDate = $("#endDate").textbox("getValue");
            /*          var state = Java.type("cn.wolfcode.crm.util.CRMConstant.Insurancebill.STATE_WAIT_ADUIT");
             console.log("state");
             console.log(state);*/
            $('#dg').datagrid('load', {
                keyword: keyword,
                beginDate: beginDate,
                endDate: endDate,
                state: state
            });
        },
        //关闭按钮
        cancel: function () {
            $('#dd').dialog("close")
        }
    };

    //调用函数集合对象
    $("a[data-cmd]").click(function () {
        var cmd = $(this).data("cmd");
        cmdObj[cmd]();
    })
})







